#ifndef GOAL_H
#define GOAL_H
//------------------------------------------------------------------------
//
//Name:   Goal.h
//
//Desc:   class to define a goal for a soccer pitch. The goal is defined
//        by two 2D vectors representing the left and right posts.
//
//        Each time-step the method Scored should be called to determine
//        if a goal has been scored.
//
//Author: Mat Buckland 2003 (fup@ai-junkie.com)
//
//------------------------------------------------------------------------


namespace OgreRefApp
{
    class Goal
    {

    private:

        Ogre::Vector3   m_vLeftPost;
        Ogre::Vector3   m_vRightPost;

        //a vector representing the facing direction of the goal
        Ogre::Vector3   m_vFacing;

        //the position of the center of the goal line
        Ogre::Vector3   m_vCenter;

        //each time Scored() detects a goal this is incremented
        int        m_iNumGoalsScored;

    public:

        Goal(Ogre::Vector3 left, Ogre::Vector3 right, Ogre::Vector3 facing):m_vLeftPost(left),
                m_vRightPost(right),
                m_vCenter((left+right)/2.0),
                m_iNumGoalsScored(0),
                m_vFacing(facing)
        {  }

        //Given the current ball position and the previous ball position,
        //this method returns true if the ball has crossed the goal line
        //and increments m_iNumGoalsScored
        inline bool Scored(Ball* ball);

        //-----------------------------------------------------accessor methods
        Ogre::Vector3 Center()
        {
            return m_vCenter;
        }
        Ogre::Vector3 Facing()
        {
            return m_vFacing;
        }
        Ogre::Vector3 LeftPost()
        {
            return m_vLeftPost;
        }
        Ogre::Vector3 RightPost()
        {
            return m_vRightPost;
        }

        int      NumGoalsScored()
        {
            return m_iNumGoalsScored;
        }
        void     ResetGoalsScored()
        {
            m_iNumGoalsScored = 0;
        }
    };


/////////////////////////////////////////////////////////////////////////

    bool Goal::Scored(Ball* ball)
    {
        /*
          if (LineIntersection2D(ball->getPosition(), ball->OldPos(), m_vLeftPost, m_vRightPost))
          {
            ++m_iNumGoalsScored;

            return true;
          }
          */

        return false;
    }
}

#endif
